﻿using UnityEngine;
using System.Collections;

public class CollectItem : MonoBehaviour {
    public Item item;
    void OnMouseDown() {
        if (Vector3.Distance(GameObject.FindGameObjectWithTag("Player").transform.position,transform.position) < 1.5f)
        {
            Inventory inv = GameObject.FindGameObjectWithTag("Player").GetComponent<Inventory>();
            if(inv.AddItem(item)){
               Destroy(gameObject);
            }
        }
    }
}
